  import { Button } from "antd";
  import { useReducer } from "react";

  type Action = { type: 'add' } | { type: 'minus' };

  const RenderComponent = () => {
    const render = (state: number, action: Action) => {
      switch (action.type) {
        case 'add':
          return state + 1;
        case 'minus':
          return state - 1;
        default:
          return state;
      }
    };

    const [count, setCount] = useReducer(render, 0);

    return (
      <div>
        <div>
          {count}
          <Button onClick={() => setCount({ type: 'add' })}>加</Button>
          <Button onClick={() => setCount({ type: 'minus' })}>减</Button>
        </div>
      </div>
    );
  };

  export default RenderComponent;
